import VueRouter from "vue-router";

import Home from "../components/Home"
import Denglu from "../components/denglu"

import Mustang from "../components/mustang"
import mustang2 from "../components/mustang2"
import mustang3 from "../components/mustang3"
import chexingpk from "../components/chexingpk"
import yuding from "../components/yuding"
import zhuce from "../components/zhuce"
import User from "../components/User"

let router= new VueRouter({

    routes: [
        { path: '/', redirect: '/denglu' },
        {
            path: '/home',
            component: Home,
            name: 'home',
            redirect:'/mustang3',
            children:[
                {
                    path:'/mustang',
                    name:'mustang',
                    component:Mustang,
                },
                {
                    path:'/mustang2',
                    name:'mustang2',
                    component:mustang2
                },
                {
                    path:'/mustang3',
                    name:'mustang3',
                    component:mustang3
                },
                {
                    path:'/chexingpk',
                    name:'chexingpk',
                    component:chexingpk
                },
                {
                    path:'/yuding',
                    name:'yuding',
                    component:yuding
                },
                {
                    path:'/User',
                    name:'User',
                    component:User
                }
            ],
           
            // 独享路由守卫 进入该路由时触发
            beforeEnter(to, from, next) {
                if (sessionStorage.getItem('userName') == 'shj123' && sessionStorage.getItem('userPass') == '031220') {
                    next()
                } else {
                    alert('您不是Mustang用户')
                }
            }
        },
        {
            path: '/denglu',
            component: Denglu,
             
        },
        {
            path: '/zhuce',
            component: zhuce,
            name:zhuce
             
        },
        
    ]
})



router.afterEach((to,from)=>{
    document.title = to.meta.title
})


export default router